#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3e5 + 10;
int a[N];
int n;
struct pp
{
    int pos, ji, ou;
} q[N];
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int dan = 0, shuang = 0;
    for (int i = n; i >= 0; i--)
    {
        q[i].pos = i;
        q[i].ji = dan;
        q[i].ou = shuang;
        if (a[i] & 1)
        {
            dan++;
        }
        else
        {
            shuang++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        if (a[i] & 1) // 奇数
        {
            ans = ans + q[i].ou + q[i].ji;
        }
        else // 偶数
        {
            ans = ans + q[i].ji + q[i].ou;
        }
    }
    cout << ans << endl;
    return 0;
}